package com.lin.java.tool.general.web;

import com.lin.java.tool.common.model.QueryPage;
import com.lin.java.tool.common.model.R;
import com.lin.java.tool.general.service.SysFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author: linjiang
 * @date: 2025/4/4
 */
@Api(tags = "文件中心")
@RestController
@RequestMapping("/file")
public class SysFileController {
    @Resource
    private SysFileService sysFileService;

    @ApiOperation("文件中心 - 列表查询")
    @PostMapping("list-page")
    public R listPage(@RequestBody QueryPage page) {
        return R.ok(sysFileService.listPage(page));
    }

    @ApiOperation("文件中心 -文件上传")
    @PostMapping("upload")
    public R uploadOss(MultipartFile file) throws Exception {
        return R.ok(sysFileService.upload(file));
    }

    @ApiOperation("文件中心 - 文件下载")
    @GetMapping("download")
    public void downloadOss(String fileId, HttpServletResponse response) throws IOException {
        sysFileService.download(fileId, response);
    }

//    @ApiOperation("文件管理 - file文件分片上传")
//    @GetMapping("uploadChunk")
//    public void uploadChunk(ChunkVO chunk) throws Exception {
//        fileService.uploadChunk(chunk);
//    }
//
//    @ApiOperation("文件管理 - file文件分片合并")
//    @GetMapping("mergeChunk")
//    public void mergeChunk(ChunkVO chunk) throws Exception {
//        fileService.mergeChunk(chunk);
//    }


}
